<template>
  <!-- 公共搜索 -->
  <div>
    <TopFilter :list="topFilterInit" :cols="3" labelWidth="90" @filterChange="changeHandle" @onCollapse="collapseHandle"></TopFilter>
    <!-- 经销商弹窗 -->
    <BaseDialog title="经销商查询" :visible.sync="visibleDealer" width="1000px" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <dealer-madal ref="dealerDialog" @close="closeDealer" />
    </BaseDialog>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import dealerMadal from '../../clue/areaBossPush/dealerMadal';

export default {
  mixins: [dictionary],
  components: {
    dealerMadal
  },
  data() {
    return {
      visibleDealer: false,
      topFilterInit: this.topFilterInitFun()
    };
  },
  methods: {
    //搜索数据
    topFilterInitFun() {
      return [
        { type: 'INPUT', label: '客户名称', fieldName: 'field1', placeholder: '请输入', initialValue: '' },
        { type: 'SELECT', label: '客户类型', fieldName: 'field2', placeholder: '请选择', initialValue: '', itemList: this.createDictList('1008') },
        { type: 'SELECT', label: '客户性质', fieldName: 'field3', placeholder: '请选择', initialValue: '', itemList: this.createDictList('1008') },
        { type: 'INPUT', label: '省份', fieldName: 'field4', placeholder: '请输入', initialValue: '' },
        { type: 'SELECT', label: '客户状态', fieldName: 'field5', placeholder: '请选择', initialValue: '', itemList: this.createDictList('1008') },
        { type: 'SELECT', label: '客户来源', fieldName: 'field6', placeholder: '请选择', initialValue: '', itemList: this.createDictList('1008') },
        { type: 'INPUT', label: '项目名称', fieldName: 'field71', placeholder: '请输入', initialValue: '' },
        // { type: 'SELECT', label: '项目状态', fieldName: 'field51', placeholder: '请选择', initialValue: '', itemList: this.createDictList('1008') },
        {
          type: 'INPUT',
          label: '经销商',
          fieldName: 'field9',
          placeholder: '请选择',
          initialValue: '',
          unitRender: () => {
            return <el-button slot="append" icon="el-icon-search" onClick={() => this.dealerHandle()}></el-button>;
          }
        }
      ];
    },
    dealerHandle() {
      this.visibleDealer = true;
    },
    closeDealer(data) {
      this.visibleDealer = data.visible;
      this.topFilterInit[8].initialValue = '经销商名';
    },
    //搜索获取数据
    changeHandle(data) {
      this.$emit('filterChange', data);
    },
    //展开收起
    collapseHandle() {
      this.$emit('onCollapse');
    }
  }
};
</script>

<style lang="less" scoped></style>
